<?php

/**
 * Reforum driver.
 * 
 * Imports settings, creates and outputs pages. 
 * @package Reforum
 */

require('library/Reforum.php');
require('library/Forum.php');
require('library/Thread.php');
require('library/Post.php');
require('library/Database.php');
require('library/Functions.php');
require('default.conf.php');

$db = Functions::getConfigValue('DB_TYPE');

switch ($db) {
	case ('MySQL'):
		require('library/MySQL.php');
		break;
	default:
		Functions::fatalError('Invalid database type specified.');
}

// check if custom config file exists
if (file_exists('custom.conf.php')) {
	include('custom.conf.php'); // import custom settings
}
else { // no custom config, enter setup mode
	//GOTO setup
}

// create Reforum instance
$reforum = new Reforum();

// get what to do from URL
$f = $_GET['f'];
$id = (int) $_GET['id'];

if ($f == 'showforum' && isset($id)) { // show threads in a forum
	$reforum->showForum($id);
}
else if ($f == 'showthread' && isset($id)) { // show posts in a thread
	$reforum->showThread($id);
}
else { // default - show all forums in each category
	$reforum->showCategories();
}

?>